
#include "dsys.h"
/* define the relocation tables that the application used */
T_GUI_RelocationTable      * tpDL_GUITable;
T_CRTL_RelocationTable     * tpDL_CRTLTable;
T_FS_RelocationTable       * tpDL_FSTable;
T_ROS33_RelocationTable    * tpDL_ROS33Table;
T_Audio_RelocationTable    * tpDL_AudioTable;
T_Dict_RelocationTable     * tpDL_DictTable;
T_VOID DL_InitRelocationPointers();
//T_VOID DL_InitRelocationPointers(T_VOID);
int errno;          /* error number */
unsigned int  seed;     /* seed of random value */
FILE    _iob[FOPEN_MAX + 1];    /* standard i/o stream, FOPEN max is 3 */
FILE    *stdin;         /* standard input */
FILE    *stdout;        /* standard output */
FILE    *stderr;        /* standard error */
time_t  gm_sec;         /* for time function */
extern void _init_lib();

T_WORD App_Main(void);

long DL_AppMain(long a)
{

	/* Init RelocationTable pointers */
	DL_InitRelocationPointers();
	_init_lib();
	/* Begin application */
	/* Here fill the application's entry function name */
	App_Main();
}



/*******************************************************************************
 *	FUNCTION	:	DL_InitRelocationPointers
 *
 *	PURPOSE		:	Init relocation table.
 *
 *	PARAMETERS
 *		Input:  No
 *		Output: No
 *		InOut:  NO
 *	Return Value : No
 *
 *	Reentrant	 : No
 ******************************************************************************/
T_VOID DL_InitRelocationPointers()
{
	T_GeneralRelocationTable *GeneralTablePtr;
	GeneralTablePtr = (T_GeneralRelocationTable*)SYS_GENERAL_RELOCATION_TABLE_ADDRESS;
	tpDL_ROS33Table = (T_ROS33_RelocationTable *)(GeneralTablePtr-> ROS33_RelocationAddress) ;
	tpDL_GUITable = (T_GUI_RelocationTable *)(GeneralTablePtr-> GUI_RelocationAddress) ;
	tpDL_FSTable = (T_FS_RelocationTable *)(GeneralTablePtr-> FS_RelocationAddress) ;
 	tpDL_CRTLTable = (T_CRTL_RelocationTable *)(GeneralTablePtr-> CRTL_RelocationAddress) ;
    tpDL_AudioTable = (T_Audio_RelocationTable *)(GeneralTablePtr-> Audio_RelocationAddress) ;
    tpDL_DictTable = (T_Dict_RelocationTable *)(GeneralTablePtr-> Dict_RelocationAddress) ;
}

int write (fhDummy, psWriBuf, iWriBytes)
{
	return 0;
}

int read (fhDummy, psReadBuf, iReadBytes)
{
	return 0;
}

void _init_lib()
{

    int iRet;

/* initalize for general */

      errno = 0;    /* clear error number */

/* initalize for io stream in io.lib */

    _iob[0]._flg = _UGETN;  /* initialize stdin stream */
    _iob[0]._buf = 0;
    _iob[0]._fd = 0;

    _iob[1]._flg = _UGETN;  /* initialize stdout stream */
    _iob[1]._buf = 0;
    _iob[1]._fd = 1;

    _iob[2]._flg = _UGETN;  /* initialize stderr stream */
    _iob[2]._buf = 0;
    _iob[2]._fd = 2;

    stdin = &_iob[0];   /* initialize each file pointer */
    stdout = &_iob[1];
    stderr = &_iob[2];

/* initialize for memory allocation address in lib.lib */
  //  iRet = ansi_InitMalloc(ALLOC_START, ALLOC_END);

/* initialize for others in lib.lib */

    seed = 1;   /* initialize random seed */
    gm_sec = -1;    /* initialize time */
}

